package cn.lblbc.lib.download.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import cn.lblbc.lib.download.db.bean.DbDownloadPartInfo

@Dao
interface DownloadPartDao {
    @Insert
    fun add(vararg dbDownloadPartInfos: DbDownloadPartInfo): LongArray?

    @Insert
    fun add(dbDownloadPartInfos: List<DbDownloadPartInfo>): LongArray?

    @Update
    fun update(vararg dbDownloadPartInfos: DbDownloadPartInfo)

    @Query("DELETE FROM download_part")
    fun deleteAll()

    @Query("SELECT * FROM download_part where id=:id")
    fun queryById(id: String): DbDownloadPartInfo?

    @Query("SELECT * FROM download_part where task_id=:taskId")
    fun queryByTaskId(taskId: String): List<DbDownloadPartInfo>?

    @Query("DELETE FROM download_part where id=:id")
    fun deleteById(id: Long)

    @Query("DELETE FROM download_part where task_id=:taskId")
    fun deleteByTaskId(taskId: String)
}